package zh.keep.all.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import zh.keep.all.Utils

/**
 * 开关屏广播
 */
class OnOrOffReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        Log.d("广播", "锁屏广播: " + intent.action)
        when (intent.action) {
            Intent.ACTION_SCREEN_OFF -> {
                Log.d("广播", "锁屏")
                Utils.startService()
            }
            Intent.ACTION_SCREEN_ON -> {
                Log.d("广播", "解锁")
                Utils.startService()
            }
            Intent.ACTION_USER_PRESENT -> {
                Log.d("广播", "开屏")
                Utils.startService()
            }
        }
    }
}